package com.design.interpreter.demo1;

// 抽象表达式接口
interface Expression {
    int interpret();
}

// 加法表达式
class AddExpression implements Expression {
    private int num1;
    private int num2;

    public AddExpression(int num1, int num2) {
        this.num1 = num1;
        this.num2 = num2;
    }

    @Override
    public int interpret() {
        return num1 + num2;
    }
}

// 上下文类，用于解释表达式
class Context {
    public int interpret(Expression expression) {
        return expression.interpret();
    }
}
